﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hegang_winform.dao.impl
{
    class Mwd : DataSaveObject
    {
        public void save(DbObject o, ref DbServiceInput input)
        {
            Random r = new Random();
            double tem_1 = Convert.ToDouble(input.Dic["主井.S7200Smart.温度4"]);
            double tem_2 = Math.Round(tem_1 + 0.2 * r.NextDouble(), 1);
            double tem_3 = Math.Round(tem_1 - 0.2 * r.NextDouble(), 1);
            double tem_4 = Math.Round(tem_1 + 0.2 * r.NextDouble(), 1);

            /*if ((tem_1 > 0 && tem_1 < 0.00001)|| (tem_2 > 0 && tem_2 < 0.00001)|| (tem_3 > 0 && tem_3 < 0.00001)|| (tem_4 > 0 && tem_4 < 0.00001))
                return;*/

            string sql = string.Format("INSERT INTO `mwd` (`wd1`,`wd2`,`wd3`,`wd4`,`TimeStamp`) VALUES ( '{0}','{1}','{2}','{3}','{4}')", tem_1.ToString(), tem_2.ToString(), tem_3.ToString(), tem_4.ToString(), System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            o.cmdNoReturn(sql);
        }
    }
}
